﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL.Project;
using BLL.ProjectArtist;
using Newtonsoft.Json;

namespace WebApplication.Project
{
    public partial class Detail : System.Web.UI.Page
    {

        public ProjectService projectService = new ProjectService();

        public ProjectArtistService projectArtistService = new ProjectArtistService();

        public List<Models.ProjectArtists> projectArtists = new List<Models.ProjectArtists>();

        public Models.Projects project = null;

        public List<string> tags = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("/");
                return;
            }

            int projectId = Convert.ToInt32(Request.QueryString["id"]);

            project = projectService.GetProjectById(projectId);

            projectArtists = projectArtistService.GetListByProjectId(projectId, 1, 999);

            if (Session["UID"] != null)
            {
                int uid = Convert.ToInt32(Session["UID"]);
                projectService.QueryIsLiked(uid, project);
                
            }

            tags = JsonConvert.DeserializeObject<List<string>>(project.Tag);
            if (tags.Count > 0)
            {
                tags.Remove("@");
            }

        }
    }
}